package com.lyubia.shop.order.controller;

import com.lyubia.shop.api.pojo.Admin;
import com.lyubia.shop.api.service.CartService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/cart")
public class CartController {

    @Reference(version = "1.0")
    private CartService cartService;

    @PostMapping("/getCartNum")
    @ResponseBody
    public Integer getCartNum(HttpSession session) {
        Admin admin = (Admin) session.getAttribute("user");
        return cartService.getCartNum(Integer.parseInt(admin.getAdminId().toString()));
    }

}
